﻿using System;
using System.Data;
using System.Collections.Generic;
using com.Model.laibendi;
namespace com.BLL.laibendi
{
    /// <summary>
    /// T_Seller
    /// </summary>
    public class T_Seller
    {
        private readonly com.DAL.laibendi.T_Seller dal = new com.DAL.laibendi.T_Seller();
        public T_Seller()
        { }
        #region  Method
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(long SellerId)
        {
            return dal.Exists(SellerId);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(com.Model.laibendi.T_Seller model)
        {
            dal.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(com.Model.laibendi.T_Seller model)
        {
            return dal.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(long SellerId)
        {

            return dal.Delete(SellerId);
        }
        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool DeleteList(string SellerIdlist)
        {
            return dal.DeleteList(SellerIdlist);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public com.Model.laibendi.T_Seller GetModel(long SellerId)
        {

            return dal.GetModel(SellerId);
        }

      

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }

  /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetSellerNameList(string strWhere)
        {
            return dal.GetSellerNameList(strWhere);
        }



        

        /// <summary>
        /// 获得前几行数据
        /// </summary>
        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            return dal.GetList(Top, strWhere, filedOrder);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<com.Model.laibendi.T_Seller> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<com.Model.laibendi.T_Seller> DataTableToList(DataTable dt)
        {
            List<com.Model.laibendi.T_Seller> modelList = new List<com.Model.laibendi.T_Seller>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                com.Model.laibendi.T_Seller model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new com.Model.laibendi.T_Seller();
                    //model.SellerId=dt.Rows[n]["SellerId"].ToString();
                    //model.MemberId=dt.Rows[n]["MemberId"].ToString();
                    model.SellerName = dt.Rows[n]["SellerName"].ToString();
                    if (dt.Rows[n]["SellerType"].ToString() != "")
                    {
                        model.SellerType = int.Parse(dt.Rows[n]["SellerType"].ToString());
                    }
                    model.Address = dt.Rows[n]["Address"].ToString();
                    model.Province = dt.Rows[n]["Province"].ToString();
                    model.City = dt.Rows[n]["City"].ToString();
                    model.Area = dt.Rows[n]["Area"].ToString();
                    model.Telephone = dt.Rows[n]["Telephone"].ToString();
                    model.BusinessTime = dt.Rows[n]["BusinessTime"].ToString();
                    model.BusinessArea = dt.Rows[n]["BusinessArea"].ToString();
                    if (dt.Rows[n]["AvgComsumption"].ToString() != "")
                    {
                        model.AvgComsumption = int.Parse(dt.Rows[n]["AvgComsumption"].ToString());
                    }
                    model.IsSupportCard = dt.Rows[n]["IsSupportCard"].ToString();
                    model.DiscountCard = dt.Rows[n]["DiscountCard"].ToString();
                    if (dt.Rows[n]["Grade"].ToString() != "")
                    {
                        model.Grade = decimal.Parse(dt.Rows[n]["Grade"].ToString());
                    }
                    model.HasPart = dt.Rows[n]["HasPart"].ToString();
                    model.BusStop = dt.Rows[n]["BusStop"].ToString();
                    model.BusLine = dt.Rows[n]["BusLine"].ToString();
                    model.Intro = dt.Rows[n]["Intro"].ToString();
                    model.feature = dt.Rows[n]["feature"].ToString();
                    model.logo = dt.Rows[n]["logo"].ToString();
                    model.DiscountContent = dt.Rows[n]["DiscountContent"].ToString();
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }

        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        //public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        //{
        //return dal.GetList(PageSize,PageIndex,strWhere);
        //}

        #endregion  Method
    }
}

